/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package views;

import control.Controller;
import control.Main;
import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
import models.Var;

/**
 *
 * @author Béo
 */
public class viewAbout extends GameCanvas {

    private Graphics g;
    private Image frame, back1, back2;

    public viewAbout() {
        super(false);
        g = getGraphics();
        try {
            frame = Image.createImage("/images/frameabout.png");
            back1 = Image.createImage(Var.BACK1);
            back2 = Image.createImage(Var.BACK2);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public void drawImage() {
        g.setColor(Var.BLACK);
        g.fillRect(0, 0, getWidth(), getHeight());
        g.drawImage(frame, 0, 0, Graphics.LEFT | Graphics.TOP);
        g.drawImage(back1, getWidth() / 2, getHeight() - 50, Graphics.HCENTER | Graphics.TOP);
        flushGraphics();
    }

    public void draw() {
        drawImage();
    }
    
    public void pointerPressed(int x, int y){
        if( x >= getWidth() / 2 - 25 && x <= getWidth() /2 + 25 && y >= 270 && y <= 320){
            g.fillRect(0, getHeight() - 60  , getWidth(), 60);
            g.drawImage(back2, getWidth() / 2, getHeight() - 50, Graphics.HCENTER | Graphics.TOP);
            flushGraphics();
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
            Controller.getInstance().showHome();
        }
    }
}
